﻿using System.IO;
using System.Text;
using System.Net;
using System.Xml;

using ECCIT;

namespace ECCIT.Net.SAML2.Protocols
{
    public class StatusDetail
    {
        // Fields
        private XmlNodeList details;

        // Properties
        public XmlNodeList Details
        {
            get { return this.details; }
            set { this.details = value; }
        }

        // Methods
        public StatusDetail()
        {
        }

        public StatusDetail(XmlElement xmlElement)
        {
            if (!IsValid(xmlElement))
            {
                throw new SerializationException("The XML is not a StatusDetail.");
            }
            this.details = xmlElement.ChildNodes;
        }

        public static bool IsValid(XmlElement xmlElement)
        {
            return (xmlElement.LocalName.Equals("StatusDetail") && xmlElement.NamespaceURI.Equals("urn:oasis:names:tc:SAML:2.0:protocol"));
        }

        public XmlElement ToXml(XmlDocument xmlDocument)
        {
            XmlElement element = xmlDocument.CreateElement("samlp", "StatusDetail", "urn:oasis:names:tc:SAML:2.0:protocol");
            if (this.details != null)
            {
                foreach (XmlElement element2 in this.details)
                {
                    element.AppendChild(xmlDocument.ImportNode(element2, true));
                }
            }
            return element;
        }
    }
}
